package com.kuang.servlet;

import com.kuang.pojo.Person;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class SessionServlet02 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
        Person person = (Person) req.getSession().getAttribute("name");
        resp.getWriter().write("取值："+ person.toString());
//        session.setAttribute("name","秦疆");
//        String sessionId=session.getId();
//        if(session.isNew()){
//            resp.getWriter().write("session创建成功："+sessionId);
//        }else {
//            resp.getWriter().write("session在服务器中存在："+ sessionId);
//        }
    }
}
